<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
<head>
  <link href="doxygen.css" rel="stylesheet" type="text/css">

  <title>Repeating Groups</title>
</head>

<body>
  <div class='header'>
    <div class='headertitle'>
      Repeating Groups
    </div>
  </div>

  <div class='contents'>
    QuickFIX has the ability to send messages containing repeating
    groups and even recursive repeating groups. All repeating
    groups begin with a field that indicates how many repeating
    groups are in a set. A group can be created by referencing a
    class named after this field scoped within the parent message
    or group.

    <br/><br/><hr/>
    <h1>Creating Messages With Repeating Groups</h1>

    <p>When a message is created the required field declaring the
    number of repeating groups is set to zero. QuickFIX will
    automatically increment field for you as you add groups.</p>See
    this code in <a href=
    "python/repeating_groups_1.html">PYTHON</a>, <a href=
    "ruby/repeating_groups_1.html">RUBY</a>
    <pre class="fragment">
    // create a market data message
    FIX42::MarketDataSnapshotFullRefresh message(FIX::Symbol("QF"));

    // repeating group in the form of MessageName::NoField
    FIX42::MarketDataSnapshotFullRefresh::NoMDEntries group;
    group.set(FIX::MDEntryType('0'));
    group.set(FIX::MDEntryPx(12.32));
    group.set(FIX::MDEntrySize(100));
    group.set(FIX::OrderID("ORDERID"));
    message.addGroup(group);

    // no need to create a new group class if we are reusing the fields
    group.set(FIX::MDEntryType('1'));
    group.set(FIX::MDEntryPx(12.32));
    group.set(FIX::MDEntrySize(100));
    group.set(FIX::OrderID("ORDERID"));
    message.addGroup(group);
</pre>

    <br/><hr/>
    <h1>Reading Messages With Repeating Groups</h1>

    <p>To pull a group out of a message you need to supply the
    group object you wish to pull out. You should first inspect the
    number of entries field (which the group is named after) to get
    the total number of groups. The message that was created above
    is now parsed in this example.</p>See this code in <a href=
    "python/repeating_groups_2.html">PYTHON</a>, <a href=
    "ruby/repeating_groups_2.html">RUBY</a>
    <pre class="fragment">
    // should be 2
    FIX::NoMDEntries noMDEntries;
    message.get(noMDEntries);

    FIX42::MarketDataSnapshotFullRefresh::NoMDEntries group;
    FIX::MDEntryType MDEntryType;
    FIX::MDEntryPx MDEntryPx;
    FIX::MDEntrySize MDEntrySize;
    FIX::OrderID orderID;

    message.getGroup(1, group);
    group.get(MDEntryType);
    group.get(MDEntryPx);
    group.get(MDEntrySize);
    group.get(orderID);

    message.getGroup(2, group);
    group.get(MDEntryType);
    group.get(MDEntryPx);
    group.get(MDEntrySize);
    group.get(orderID);
</pre>
  </div>
</body>
</html>
